import $axios1 from "@/network/shiyong1.js";
import $axios from "@/network/index.js";


/**
 * 获取目录结构
 * @returns {*}
 */
export const catalogueService = () => {
    return $axios({
        method: 'GET',
        url: '/catalogue/selectCatalogueTree/0',
    })
}

/**
 * 获取目录下图层
 */
export const catalogueByParentIdService = (parentId) => {
    return $axios({
        method: 'GET',
        url: '/catalogue/selectCatalogueTree/',
        params: {
            "parentId": parentId
        }
    })
}

/**
 * 根据id获取名称
 */
export const selectCatalogueById = (id) => {
    return $axios({
        method: 'GET',
        url: '/catalogue/selectCatalogueById/' + id,
    })
}

/**
 * 获取shp文件数据
 * @returns {*}
 */
export const getFeatureByJson = (name, year,polymerization) => {

    var data;
    if (name == "企业") {
       data = {
            "cliped": "false",
            "start": 1,
            "filter": {
            "type": "And",
                "condition": [{
                "geometryType": "Point",
                "propertyName": "Name",
                "queryType": "Intersects",
                "srsCode": "4326",
                "value": "114.207,36.449"
            }]
        },
            "layerName": name,
            "maxFeatures": 0,
            "queryFields": "*"
        }
    }else if (name == "grain_output" || name == "population"){
        data = {
            "cliped": "false",
            "start": 1,
            "filter": {
                "type": "And",
                "condition": [{
                    "geometryType": "Point",
                    "propertyName": "the_geom",
                    "queryType": "Intersects",
                    "srsCode": "4326",
                    "value": "114.207,36.449"
                }]
            },
            "layerName": name + year,
            "maxFeatures": 0,
            "queryFields": "*"
        }
    }else if (name == "月平均气温" || name == "月降水量"){
        data = {
            "cliped": "false",
            "start": 1,
            "filter": {
                "type": "And",
                "condition": [{
                    "geometryType": "Point",
                    "propertyName": "the_geom",
                    "queryType": "Intersects",
                    "srsCode": "4326",
                    "value": "114.207,36.449"
                }]
            },
            "layerName": name + "2021年",
            "maxFeatures": 0,
            "queryFields": "*"
        }
    }else if (name == "计划生育数据" || name == "已婚育龄妇女孩次分类及节育措施情况" || name == "村庄粮食产量情况表" || name == "乡镇粮食产量情况表" || name == "月平均气温"
        || name == "月降水量" || name == "村庄人口情况" || name == "乡镇人口情况表" || name == "造林面积" || name == "农业主要产品生产情况表" || name == "农村生产条件"
        || name == "农村牲畜情况" || name == "村镇牲畜情况"){
        data = {
            "cliped": "false",
            "start": 1,
            "filter": {
                "type": "And",
                "condition": [{
                    "geometryType": "Point",
                    "propertyName": "the_geom",
                    "queryType": "Intersects",
                    "srsCode": "4326",
                    "value": "114.207,36.449"
                }]
            },
            "layerName": name + year + '年',
            "maxFeatures": 0,
            "queryFields": polymerization
        }
    }else if (year == 0){
        data = {
            "cliped": "false",
            "start": 1,
            "filter": {
                "type": "And",
                "condition": [{
                    "geometryType": "Point",
                    "propertyName": "the_geom",
                    "queryType": "Intersects",
                    "srsCode": "4326",
                    "value": "114.207,36.449"
                }]
            },
            "layerName": name,
            "maxFeatures": 0,
            "queryFields": "*"
        }
    }else {
        data = {
            "cliped": "false",
            "start": 1,
            "filter": {
                "type": "And",
                "condition": [{
                    "geometryType": "Point",
                    "propertyName": "the_geom",
                    "queryType": "Intersects",
                    "srsCode": "4326",
                    "value": "114.207,36.449"
                }]
            },
            "layerName": name,
            "maxFeatures": 0,
            "queryFields": "*"
        }
    }

    return $axios1({
        method: 'POST',
        data: data
    })
}